﻿package com.vicentediaz.view.imageviewer
{
    import com.greensock.*;
    import com.vicentediaz.data.*;
    import flash.display.*;
    import flash.events.*;

    public class CanvasGalleryItem extends Sprite
    {
        public var id:uint;

        public function CanvasGalleryItem(param1:uint = 0)
        {
            this.id = param1;
            var _loc_2:* = Gallery.getInstance().getThumbBitmapData(param1);
            var _loc_3:* = new Bitmap(_loc_2, "auto", true);
            _loc_3.x = (-_loc_3.width) * 0.5;
            _loc_3.y = (-_loc_3.height) * 0.5;
            addChild(_loc_3);
            alpha = 0.3;
            addEventListener(MouseEvent.ROLL_OVER, this.onItemRollOver, false, 0, true);
            addEventListener(MouseEvent.ROLL_OUT, this.onItemRollOut, false, 0, true);
            cacheAsBitmap = true;
            return;
        }// end function

        public function stopMouseEvents() : void
        {
            removeEventListener(MouseEvent.ROLL_OVER, this.onItemRollOver);
            removeEventListener(MouseEvent.ROLL_OUT, this.onItemRollOut);
            return;
        }// end function

        private function onItemRollOver(param1:MouseEvent) : void
        {
            if (CanvasGallery.getInstance().drawing)
            {
                return;
            }// end if
            TweenMax.to(this, 0.3, {alpha:1});
            Sounds.getInstance().playById("ROLLOVER_THUMB", 1, (-(stage.stageWidth / 2 - stage.mouseX)) / stage.stageWidth);
            return;
        }// end function

        private function onItemRollOut(param1:MouseEvent) : void
        {
            TweenMax.to(this, 0.3, {alpha:0.3});
            return;
        }// end function

    }
}
